import { request, upload } from '@/utils/request'

export const loginApi = (params: object) => {
  return request({
    url: '/api/wxApplet/appletLogin',
    method: 'POST',
    data: {
      ...params
    },
    noToken: true
  })
}
// /common/front/uploads
// 多文件上传
export const uploadImagesApi = (data: any) => {
  return upload({
    url: '/common/front/uploads',
    method: 'POST',
    filePath: data.filePath,
    name: 'files'
  })
}

// 上传图片 展示无
export const uploadImageApi = (data: any) => {
  return upload({
    url: '/common/front/upload',
    method: 'POST',
    filePath: data.filePath
  })
}

// /api/wxApplet/checkAppletMemberExist
// 判断是否需要获取手机号
export const checkAppletMemberExistApi = (code: string) => {
  return request({
    url: '/api/wxApplet/checkAppletMemberExist',
    method: 'POST',
    data: { code },
    noToken: true
  })
}

// 根据token获取用户信息
export const getUserInfoByTokenApi = () => {
  return request({
    url: '/api/wxApplet/userInfo'
  })
}
// /api/community/member/updateUserInfo
// 修改用户信息
export const updateUserInfoApi = (params: object) => {
  return request({
    url: '/api/community/member/updateUserInfo',
    method: 'POST',
    data: {
      ...params
    }
  })
}

// 获取房屋列表
// /api/community/member/building/record/list
export const getBuildingListApi = (params: object) => {
  return request({
    url: '/api/community/member/building/record/list',
    method: 'GET',
    data: {
      ...params
    }
  })
}

// 获取当前住户的房屋信息
// /api/community/member/building/record/detail
export const getBuildingDetailApi = (params: object) => {
  return request({
    url: '/api/community/member/building/record/detail',
    method: 'GET',
    data: {
      ...params
    }
  })
}

// 退出登录
// /api/wxApplet/appletLogout
export const logoutApi = () => {
  return request({
    url: '/api/wxApplet/appletLogout',
    method: 'POST'
  })
}
